package com.gonsin.gview.model.tab;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.gonsin.gview.model.GBoardModel;
import com.gonsin.gview.model.i18n.TCloneable;
import com.gonsin.i18n.logic.T;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;
import java.util.Map;

@ApiModel("tab的区域")
@Data
public class GTabModel implements TCloneable<GTabModel> {

    @ApiModelProperty("页面标题")
    private String title;

    @ApiModelProperty("子区域")
    private GBoardModel board;

    @ApiModelProperty("该页面所需的参数")
    private List<String> props;

    @ApiModelProperty("后台传入的props")
    private Map<String, Object> serverProps;

    @Override
    public GTabModel tClone() {
        GTabModel model = new GTabModel();
        BeanUtil.copyProperties(this, model, CopyOptions.create().setIgnoreNullValue(true));
        if(title != null){
            model.title = T.t(title);
        }
        if(board != null){
            model.board = board.tClone();
        }
        model.serverProps = serverProps;
        model.props = props;
        return model;
    }
}
